﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace simulate_control.Basic
{
    #region USING
    using simulate_control.Helpers;
    using DevComponents.DotNetBar;
    #endregion

    public partial class FrmZoom : Form
    {
        #region VARIABLES
        public EventHandler Handler { get; set; }
        private const int OFFY = 28;
        private int FIRSTY = 9;
        private int Selected = 0;
        private Dictionary<int, double> dict = new Dictionary<int, double>();
        #endregion

        #region METHODS
        public FrmZoom()
        {
            InitializeComponent();
        }

        public void InitValuesSet()
        {
            dict.Add(0, 0.02);
            dict.Add(1, 0.05);
            dict.Add(2, 0.1);
            dict.Add(3, 0.2);
            dict.Add(4, 0.5);
            dict.Add(5, 1);
            dict.Add(6, 2);
            dict.Add(7, 5);
            dict.Add(8, 10);
            dict.Add(9, 20);
            dict.Add(10, 40);
            dict.Add(11, 80);
            dict.Add(12, 160);
            dict.Add(13, 320);
        }

        public void ProcessKeyEvent(KEY keyEvent)
        {
            if (keyEvent == KEY.ENTER)
            {
                this.Handler(this, new TransferDataEvent(lblVal.Text));
                this.Close();
            }
            else
            {
                switch (keyEvent)
                {
                    case KEY.UP:
                        GetNextVal();
                        break;
                    case KEY.DOWN:
                        GetPreviousVal();
                        break;
                }
            }
        }

        public void GetNextVal()
        {
            if (Selected == 13)
            {
                Selected = 0;
            }
            else
            {
                Selected++;
            }
            lblVal.Text = dict[Selected].ToString();
        }

        public void GetPreviousVal()
        {
            if (Selected == 0)
            {
                Selected = 13;
            }
            else
            {
                Selected--;
            }
            lblVal.Text = dict[Selected].ToString();
        }

        private void FrmSelectOptions_Load(object sender, EventArgs e)
        {
            InitValuesSet();
            lblVal.Text = dict[Selected].ToString();
        }
        #endregion
    }
}
